package com.zsg.androidsipphone.util;


import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.*;


/**
 * 线程配置类
 *
 * @author zsg
 */
public class ThreadPoolConfig {

    public static ExecutorService buildMyThreadPool(){
        // 例如，"rpc-pool-%d"会产生像线程名称 "rpc-pool-0"，"rpc-pool-1"，"rpc-pool-2"
        ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("thread-call-runner-%d").build();

        return new ThreadPoolExecutor(
                5
                ,15
                ,0L
                , TimeUnit.MILLISECONDS
                ,new ArrayBlockingQueue<>(1000)
                ,threadFactory
                ,new ThreadPoolExecutor.CallerRunsPolicy()
        );
    }

}
